package com.example.usharingtest.activities;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.usharingtest.R;
import com.example.usharingtest.model.Article;
import com.squareup.picasso.Picasso;

public class ArticleViewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.userpostdetail);

        Article article = (Article)getIntent().getSerializableExtra("art");
        ImageView Puphoto = (ImageView)findViewById(R.id.pu_photo);
        TextView puname = (TextView)findViewById(R.id.pu_name);
        TextView putime = (TextView)findViewById(R.id.pu_time);
        TextView pucontent = (TextView)findViewById(R.id.pu_content);
        ImageView puimage = (ImageView)findViewById(R.id.pu_image);

        if(article == null){
            System.out.println("未能得到传输的数据");
        }

        Picasso.with(ArticleViewActivity.this).load(this.getResources().getString(R.string.URL_SERVER)+article.getUser().getUserphotopath()).placeholder(R.drawable.loading).into(Puphoto);
        puname.setText(article.getUser().getUsername());
        putime.setText(article.getPublishtime().toString());
        pucontent.setText(article.getContent());
        Picasso.with(ArticleViewActivity.this).load(this.getResources().getString(R.string.URL_SERVER)+article.getPhotopath()).placeholder(R.drawable.loading).into(puimage);
    }
}
